/**
 * 菜单详情对话框
 */
var StarShopApplyDlg = {
    StarShopApplyDlgData: {},
    ztreeInstance: null,
    validateFields: {
    	user_name: {
            validators: {
                notEmpty: {
                    message: '姓名不能为空'
                }
            }
        },
        binding_phone: {
            validators: {
                notEmpty: {
                    message: '绑定手机不能为空'
                }
            }
        },
        flow_no: {
            validators: {
                notEmpty: {
                    message: '缴费回执号不能为空'
                }
            }
        },
        pay_money: {
            validators: {
                notEmpty: {
                    message: '实付金额不能为空'
                }
            }
        },
        pay_type: {
            validators: {
        		notEmpty: {
					message: '支付方式不能为空'
				}
            }
        },
        pay_channel: {
            validators: {
        		notEmpty: {
					message: '支付渠道不能为空'
				}
            }
        },
        pay_time: {
            validators: {
        		notEmpty: {
					message: '支付时间不能为空'
				}
            }
        }
        
    }
};

/**
 * 清除数据
 */
StarShopApplyDlg.clearData = function () {
    this.StarShopApplyDlgData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
StarShopApplyDlg.set = function (key, val) {
        this.StarShopApplyDlgData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
        return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
StarShopApplyDlg.get = function (key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
StarShopApplyDlg.close = function () {
    parent.layer.close(window.parent.StarShopApply.layerIndex);
}

/**
 * 收集数据
 */
StarShopApplyDlg.collectData = function () {
    this.set('user_name').set('binding_phone').set('recommendation_no').set('flow_no').set('pay_type').set('pay_channel').set('pay_money').set('isUp')
    if($("#pay_time").val()!="")
    {
    	
    	this.set('pay_time');
    }
   
}

/**
 * 验证数据是否为空
 */
StarShopApplyDlg.validate = function () {
    $('#starShopApplyInfoForm').data("bootstrapValidator").resetForm();
    $('#starShopApplyInfoForm').bootstrapValidator('validate');
    return $("#starShopApplyInfoForm").data('bootstrapValidator').isValid();
}
/**
 * 提交添加用户
 */
StarShopApplyDlg.addSubmit = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/partnerApply/addStarShop", function (data) {
        if(data.code == 200) {
            Feng.success("添加成功!");
            window.parent.StarShopApply.table.refresh();
            StarShopApplyDlg.close();
        }else{
            Feng.error(data.message);
        }
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.StarShopApplyDlgData);
    ajax.start();
    
    
}
$(function()
{
	Feng.initValidator("starShopApplyInfoForm", StarShopApplyDlg.validateFields);
});